#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    int i = 0, j = 0, arr[1000];
    for (i; i < n; i++) {
        scanf("%d", &arr[i]);
    }
    for (j = i; j < n + m; j++) {
        scanf("%d", &arr[j]);
    }
    for (i = 0; i < n + m - 1; i++) {
        for (j = 0; j < n + m - i - 1; j++) {
            if (arr[j] > arr[j + 1]) {
                int t = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = t;
            }
        }
    }
    for (i = 0; i < n + m; i++) {
        printf("%d ", arr[i]);
    }
    return 0;
}